package com.agua.enturno.servicios.impl;

import com.agua.enturno.persistencia.dao.ServicioDAO;
import com.agua.enturno.servicios.ServicioService;
import com.agua.enturno.vista.dto.AgendaDTO;
import com.agua.enturno.vista.dto.ServicioDTO;
import com.agua.enturno.vista.dto.assemblers.AgendaAssembler;
import com.agua.enturno.vista.dto.assemblers.ServicioAssembler;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public class ServicioServiceImpl implements ServicioService {

	private ServicioDAO servicioDAO;
	private ServicioAssembler servicioAssembler;
	private AgendaAssembler agendaAssembler;
	
	
	/*------------------------------------ Public methods ----------------------------------*/

	@Override
	@Transactional
	public ServicioDTO findById(Long id) {
		return servicioAssembler.assemble(servicioDAO.findById(id));
	}
	
	@Override
	@Transactional
	public List<AgendaDTO> findAgendas(Long servicioId) {
		return agendaAssembler.assemble(servicioDAO.findById(servicioId).getAgendas());
	}

	/*--------------------------------------------------------------------------------------*/
	/*---------------------------------- Geters and seters ---------------------------------*/

	public void setServicioDAO(ServicioDAO servicioDAO) {
		this.servicioDAO = servicioDAO;
	}

	public void setServicioAssembler(ServicioAssembler servicioAssembler) {
		this.servicioAssembler = servicioAssembler;
	}

	public void setAgendaAssembler(AgendaAssembler agendaAssembler) {
		this.agendaAssembler = agendaAssembler;
	}
	
	/*--------------------------------------------------------------------------------------*/

}
